package com.guang.syncronized.syncronizedbatchrevoke;

import org.openjdk.jol.info.ClassLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

/**
 * @Description 禁用掉偏向锁：-XX:-UseBiasedLocking
 *              加锁直接称为轻量级锁
 * @Author liguang
 * @Date 2022/10/23/16:10
 */
public class SyncronizedFobbindonBiasTest {

    private final static Logger logger = LoggerFactory.getLogger(SyncronizedFobbindonBiasTest.class);

    public static void main(String[] args) throws InterruptedException {
        TimeUnit.SECONDS.sleep(5);
        Object lock = new Object();
        logger.info("无锁不可偏向，001，打印对象头：{}", ClassLayout.parseInstance(lock).toPrintable());
        synchronized (lock){
            logger.info("偏向锁,000，打印对象头：{}", ClassLayout.parseInstance(lock).toPrintable());
        }
    }
}
